<!--
  移动签批->公文详情->发文->签发
-->
<template>
  <view>
    <van-popup v-model="showCompo" closeable round position="bottom" :style="{ height: '80%' }"
               @click-close-icon="toClose" @click-overlay="toClose">
      <van-row type="flex" justify="center">
        <van-col offset="3" span="8">
          <van-cell value="签发"/>
        </van-col>
      </van-row>
      <van-form @submit="onSubmit">
        <van-cell-group inset>
          <van-field
              v-model="qfopinion"
              rows="6"
              autosize
              label="签发意见"
              type="textarea"
              maxlength="150"
              show-word-limit
              clearable
              placeholder="请输入签发意见"
              :rules="[{ required: true, message: '内容不能为空' }]"
          />
        </van-cell-group>
        <view class="css">
          <van-row type="flex" justify="space-around">
            <van-col span="10">
              <van-button type="info" round plain hairline block @click.prevent="toClose">取消</van-button>
            </van-col>
            <van-col span="10">
              <van-button type="info" round block native-type="submit">确定</van-button>
            </van-col>
          </van-row>
        </view>
      </van-form>
    </van-popup>
  </view>
</template>

<script>
import Toast from 'vant';

export default {
  components: {},
  props: {
    showIssuance: {
      type: Boolean,
      default: false
    },
    paramObject: {
      type: Object
    }
  },
  watch: {
    showIssuance(val) {
      this.showCompo = val
    },
  },
  data() {
    return {
      showCompo: false,//组件是否显示
      qfopinion: '',//签发意见
    }
  },
  mounted() {
    this.$nextTick(function () {
    })
  },
  methods: {

    onSubmit() {
      this.saveopinion()
      this.$emit('closeIssuance', this.showIssuance);
    },
    toClose() {
      this.$emit('closeIssuance', this.showIssuance);
    },

    //签发
    saveopinion() {
      const _this = this
      this.$httploading({
        url: this.$http.adornUrl(`/caac/oa/component/approval/saveopinion?systemKey=` + this.cache.get('userInfo').systemKey + `&systemFlag=` + this.cache.get('userInfo').systemFlag),
        method: 'post',
        data: this.$http.adornData({
          'actInstId': this.paramObject.actInstId,//
          'isApproval': '1',//核稿状态，默认传1
          'opinion': this.qfopinion,
          'opiniontype': 'jldReview',//
          'proInstId': this.paramObject.proInstId,//发文详情返回的proInstId
          'workItemId': this.paramObject.workitemId//
        })
      }).then(({data}) => {
        if (data.code == 200) {
          //通知父页面重新加载数据
          _this.qfopinion = ''//成功后清空
          _this.$toast('操作成功')
          _this.$emit('refreshBtnGroup', true)//通知父组件重新加载数据
        } else {
          console.log("签发失败--data: " + JSON.stringify(data));
        }

      })
    },
  },
};
</script>

<style scoped>
	.cu-form-group{
		border: 2rpx solid #e4e4e4;
		border-radius: 10rpx;
	}
	.textarea{
		margin: 32rpx 0 30rpx;
		height: 300rpx;
		width: 100%;
		line-height: 40rpx;
		-webkit-box-flex: 1;
		-webkit-flex: 1;
		flex: 1;
		font-size: 32rpx;
		padding: 0;


	}
	.css {
		text-align: center;
		position: fixed;
		left: 0;
		right: 0;
		bottom: 3%;
	}

	/deep/ .van-cell__title {
		min-width: 20%;

		span {
			display: inline-block;
			text-align: left;
			word-break: break-all;
		}
	}


</style>
